home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / AvantBrowser / asetup.exe / _data / webkit / chrome_100_percent.pak / Unnamed File 000033.txt < prev    next >
Text File  |  2013-04-03  |  3KB  |  71 lines

  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4.  
  5. // Custom bindings for the fileSystem API.
  6.  
  7. var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
  8. var fileSystemNatives = requireNative('file_system_natives');
  9. var GetIsolatedFileSystem = fileSystemNatives.GetIsolatedFileSystem;
  10. var lastError = require('lastError');
  11.  
  12. chromeHidden.registerCustomHook('fileSystem', function(bindingsAPI) {
  13.   var apiFunctions = bindingsAPI.apiFunctions;
  14.   function bindFileEntryFunction(functionName) {
  15.     apiFunctions.setUpdateArgumentsPostValidate(
  16.         functionName, function(fileEntry, callback) {
  17.       var fileSystemName = fileEntry.filesystem.name;
  18.       var relativePath = fileEntry.fullPath.slice(1);
  19.       return [fileSystemName, relativePath, callback];
  20.     });
  21.   }
  22.   ['getDisplayPath', 'getWritableEntry', 'isWritableEntry']
  23.       .forEach(bindFileEntryFunction);
  24.  
  25.   function bindFileEntryCallback(functionName) {
  26.     apiFunctions.setCustomCallback(functionName,
  27.         function(name, request, response) {
  28.       if (request.callback && response) {
  29.         var callback = request.callback;
  30.         request.callback = null;
  31.  
  32.         var fileSystemId = response.fileSystemId;
  33.         var baseName = response.baseName;
  34.         var fs = GetIsolatedFileSystem(fileSystemId);
  35.  
  36.         try {
  37.           fs.root.getFile(baseName, {}, function(fileEntry) {
  38.             callback(fileEntry);
  39.           }, function(fileError) {
  40.             lastError.set('Error getting fileEntry, code: ' + fileError.code);
  41.             callback();
  42.           });
  43.         } catch (e) {
  44.           lastError.set('Error in event handler for onLaunched: ' + e.stack);
  45.           callback();
  46.         }
  47.       }
  48.     });
  49.   }
  50.   ['getWritableEntry', 'chooseEntry'].forEach(bindFileEntryCallback);
  51.  
  52.   // TODO(benwells): Remove these deprecated versions of the functions.
  53.   chrome.fileSystem.getWritableFileEntry = function() {
  54.     console.log("chrome.fileSystem.getWritableFileEntry is deprecated");
  55.     console.log("Please use chrome.fileSystem.getWritableEntry instead");
  56.     chrome.fileSystem.getWritableEntry.apply(this, arguments);
  57.   };
  58.  
  59.   chrome.fileSystem.isWritableFileEntry = function() {
  60.     console.log("chrome.fileSystem.isWritableFileEntry is deprecated");
  61.     console.log("Please use chrome.fileSystem.isWritableEntry instead");
  62.     chrome.fileSystem.isWritableEntry.apply(this, arguments);
  63.   };
  64.  
  65.   chrome.fileSystem.chooseFile = function() {
  66.     console.log("chrome.fileSystem.chooseFile is deprecated");
  67.     console.log("Please use chrome.fileSystem.chooseEntry instead");
  68.     chrome.fileSystem.chooseEntry.apply(this, arguments);
  69.   };
  70. });
  71.